package com.ekuaitu.kuaitustaff.utils;

import android.content.Context;
import android.content.Intent;
import android.webkit.CookieManager;

import com.ekuaitu.kuaitustaff.activity.AddCommentActivity;
import com.ekuaitu.kuaitustaff.activity.CarFinishTaskActivity;
import com.ekuaitu.kuaitustaff.activity.CarScanActivity;
import com.ekuaitu.kuaitustaff.activity.CarTaskActivity;
import com.ekuaitu.kuaitustaff.activity.FindCarActivity;
import com.ekuaitu.kuaitustaff.activity.LoginNewActivity;
import com.ekuaitu.kuaitustaff.activity.WebViewActivity;
import com.ekuaitu.kuaitustaff.api.UrlConstant;

public class IntentUtil {
    /**
     * 跳转到webview页面
     *
     * @param context
     * @param url
     */
    public static void toWebViewActivity(Context context, String url) {
        Intent intent = new Intent();
        intent.setClass(context, WebViewActivity.class);
        intent.putExtra(IntentKey.INTENT_WEBVIEW_URL, url);
        /*intent.putExtra("title", title);*/
        context.startActivity(intent);
    }

    /*跳转到登陆页面*/
    public static void toLoginActivity(Context context) {
        Intent intent = new Intent();
        intent.setClass(context, LoginNewActivity.class);
        context.startActivity(intent);
    }

    /*跳转到确认完成任务页面*/
    public static void toCarTaskActivity(Context context, String orderId, String carId, String shortName, String licenseTag, String isOperate, String locationName) {
        Intent intent = new Intent(context, CarTaskActivity.class);
        intent.putExtra(IntentKey.INTENT_ORDER_ID, orderId);
        intent.putExtra(IntentKey.INTENT_CAR_ID, carId);
        intent.putExtra(IntentKey.INTENT_TASKTYPE, shortName);
        intent.putExtra(IntentKey.INTENT_LICENSETAG, licenseTag);
        intent.putExtra(IntentKey.INTENT_ISOPERATE, isOperate);
        intent.putExtra(IntentKey.INTENT_LOCATIONNAME, locationName);
        context.startActivity(intent);
    }

    /*跳转到完成任务回到首页页面*/
    public static void toCarFinishTaskActivity(Context context, String orderId, String carId, String licenseTag) {
        Intent intent = new Intent(context, CarFinishTaskActivity.class);
        intent.putExtra(IntentKey.INTENT_ORDER_ID, orderId);
        intent.putExtra(IntentKey.INTENT_CAR_ID, carId);
        intent.putExtra(IntentKey.INTENT_LICENSETAG, licenseTag);

        context.startActivity(intent);
    }

    /*跳转到交停车费页面*/
    public static void toCarParkingFeeActivity(Context context, String orderId, String carId, String licenseTag) {
        Intent intent = new Intent(context, WebViewActivity.class);
        CookieManager cookieManager = CookieManager.getInstance();
        cookieManager.setCookie(UrlConstant.Request.PARK_FEE, "orderId=" + orderId);
        cookieManager.setCookie(UrlConstant.Request.PARK_FEE, "carId=" + carId);
        cookieManager.setCookie(UrlConstant.Request.PARK_FEE, "licenseTag=" + licenseTag);
        intent.putExtra(IntentKey.INTENT_WEBVIEW_URL, UrlConstant.Request.PARK_FEE);
        context.startActivity(intent);
    }

    //跳转至车辆扫描
    public static void toCarScanActivity(Context context) {
        Intent intent = new Intent();
        intent.setClass(context, CarScanActivity.class);
        context.startActivity(intent);
    }

    //跳转到追车界面
    public static void toFindCarActivity(Context context) {
        Intent intent = new Intent();
        intent.setClass(context, FindCarActivity.class);
        context.startActivity(intent);
    }

    //跳转到备注补充界面
    public static void toAddCommentActivity(Context context) {
        Intent intent = new Intent();
        intent.setClass(context, AddCommentActivity.class);
        context.startActivity(intent);
    }
}
